<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 控制能否向对象当中添加属性
    const user = {
      name: "小灰",
      age: 18,
    };
    Object.preventExtensions(user); //禁止添加属性
    // isExtensible用于判断是否可添加属性
    if (Object.isExtensible(user)) {
      user.site = "baidu.com";
      console.log(user); //使用严格模式会报错
    }
  </script>
</html>
